import QtQuick 2.0
import QtQuick.Controls 2.5
import QtQuick.Layouts 1.3

ApplicationWindow {
    id:root;
    visible: true;
    visibility:"Maximized";
    height: 500;
    width: 700;
    title: qsTr("Report");

    property var currentView: null

    menuBar: MenuBar{
        Menu{
            title: qsTr("File");
//            MenuItem{
//                action: Action{
//                    id:folderAction;
//                    text: qsTr("打开...");
//                    onTriggered: {
//                        //folderDialog.open();
//                    }

//                }
//            }

            MenuItem{
                text:qsTr("Quit");
                onTriggered: Qt.quit();
            }
        }
        Menu{
            title: qsTr("Device");
            MenuItem{
                action: Action{
                    id:ctAction;
                    text: qsTr("CL2030");
                    onTriggered: {
                        showView("main.qml");
                    }
                }
            }
            MenuItem{
                action: Action{
                    id:cl3115Action;
                    text: qsTr("CL3115");
                    onTriggered: {
                        showView("mainRefm.qml");
                    }
                }
            }
        }
    }
    header:ToolBar{
        RowLayout{
            ToolButton{
                text: qsTr("CL2030");
                action: ctAction
                hoverEnabled: true
                ToolTip.visible: hovered
                ToolTip.delay: 200
                ToolTip.text:qsTr("CT Excel");
            }
            ToolSeparator{}
            ToolButton{
                text: qsTr("CL3115");
                action: cl3115Action
                hoverEnabled: true
                ToolTip.visible: hovered
                ToolTip.delay: 200
                ToolTip.text:qsTr("标准表Excel");
            }
        }
    }

    Item{
        id:contentView;
        anchors.fill:parent;
    }

    footer:Rectangle{
        height: 25;
        width: root.width;
        Text{text: "...";}
    }

    function showView(dtype){
        if(currentView!=null)
            currentView.destroy();
        var component = Qt.createComponent(dtype);
        currentView = component.createObject(contentView,{parent:root});
    }

}
